package top.buyibuyi.course.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.buyibuyi.course.pojo.Admin;
import top.buyibuyi.course.pojo.Course;

import java.util.List;

@Mapper
public interface SelectCourseDao {
    @Select("<script>"
            + "select * from course where 1=1 "
            +"<if test=\"cname != null and cname != ''\">"
            +" and cname LIKE concat('%', #{cname}, '%')"
            +"</if>"
            +"and id limit #{startPage},#{limit}"
            +"</script>")
    List<Course> selectCourse(@Param("startPage") int startPage, @Param("limit") int limit, @Param("cname") String cname);

    @Select("<script>"
            + "select count(*) as 'totalpage' from course where 1=1 "
            +"<if test=\"cname != null and cname != ''\">"
            +" and cname LIKE concat('%', #{cname}, '%')"
            +"</if>"
            +"</script>")
    int selectCount(Course cname);

    @Select("select * from course where id = #{courseid}")
    Course selectCourseById(int id);
}
